package cn.bytecollege.user.controller;

import cn.bytecollege.common.entity.Address;
import cn.bytecollege.user.service.AddressService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "AddressFindByIdController",value = "/user/findbyid")
public class AddressFindByIdController extends HttpServlet {
    private AddressService addressService=null;
    public AddressFindByIdController(){
        addressService=new AddressService();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      String addressId=request.getParameter("addressdId");
      Address address=addressService.findById(Integer.valueOf(addressId));
      request.setAttribute("address",address);
      request.getRequestDispatcher("/updateAddress.jsp").forward(request,response);

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     doPost(request, response);
    }
}
